/**
  ******************************************************************************
  * @author     Chris
  * @since      2024/6/18 17:31
  *
  * @file       pd_adc.h
  * @brief      Header file of ADC peripheral driver.
  *
  * @note       This file contains the ADC object declaration.
  *
  * @warning    None.
  ******************************************************************************
  * Change Logs:
  *   Date          Author       Notes
  *   2024/6/18     Chris        the first version
  *
  ******************************************************************************
  */


#ifndef JLC_SKY_ADC_H
#define JLC_SKY_ADC_H

#include "pd_gpio.h"
#include "pd_adc_ch.h"
#include "drivers.h"

typedef struct ADCBaseDef ADCBase;

struct ADCBaseDef {
    ADC_TypeDef *ADCx;
    ADCCh *adcChannel;

    uint32_t Resolution;
    uint32_t DataAlignment;
    uint32_t SequencersScanMode;    // ADC scan mode(ADC_CR1_SCAN, Bit 8)

    uint32_t CommonClock;
#if defined(ADC_MULTIMODE_SUPPORT)
    uint32_t Multimode;
    uint32_t MultiDMATransfer;
    uint32_t MultiTwoSamplingDelay;
#endif /* ADC_MULTIMODE_SUPPORT */

    void (*init)(ADCBase *this);
};

extern const struct ADCBaseClass {
    /**
     *
     * @param ADCx               ADC instance
     * @param adcChannel         ADC GPIO/RANK/Channel
     * @param SequencersScanMode ADC sequencers scan mode:DISABLE, single conversion mode; ENABLE, sequence conversions mode.
     * @return
     */
    ADCBase *(*build)(ADC_TypeDef *ADCx, ADCCh *adcChannel, uint32_t SequencersScanMode);
} ADCBaseBuilder;

#endif //JLC_SKY_ADC_H
